<template>
    <div class="wrap">
        <div class="header">
            <van-search show-action shape="round" placeholder="请输入你想要搜索的商品名称" :value="content" @search="getList($event.mp.detail)" @cancel="goBack"/>
        </div>
        <ul class="list">
            <li v-for="(item, index) in list" :key="index" @click="handleChecked(item)">{{item.schoolName}}</li>
        </ul>
    </div>
</template>
<script>
export default {
    data () {
        return {
            list: [],
            content: ''
        };
    },
    methods: {
        getList (content=this.content) {
            this.$api.getSchollList({
                schoolName: content.trim()
            }).then(({data}) => {
                this.list = data.schoolList;
            });
        },
        goBack() {
            wx.navigateBack({
                delta: 1,
            });
        },
        handleChecked(item) {
            this.$setStorage('schoolInfo', item);
            this.goBack();
        }
    },
    onShow () {
        this.getList();
    }
}
</script>
<style lang="scss" scoped>
.list {
    li {
        height: 40px;
        line-height: 40px;
        padding: 0px 15px;
        border-bottom: 1px solid $grey-border-color;
    }
}
</style>